{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.12-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3",
   "language": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from scipy.stats import t\n",
    "import glob\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "['C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Host\\\\db_oracle_11g.csv',\n",
       " 'C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Host\\\\dcos_container.csv',\n",
       " 'C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Host\\\\dcos_docker.csv',\n",
       " 'C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Host\\\\mw_redis.csv',\n",
       " 'C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Host\\\\os_linux.csv']"
      ]
     },
     "metadata": {},
     "execution_count": 2
    }
   ],
   "source": [
    "path = \"C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Host\\\\\"\n",
    "all_files = glob.glob(path + \"*.csv\")\n",
    "all_files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfs = []\n",
    "for filename in all_files:\n",
    "    df = pd.read_csv(filename, index_col=None)\n",
    "    dfs.append(df)\n",
    "df = pd.concat(dfs, axis=0, ignore_index=True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "                 itemid                      name     bomc_id      timestamp  \\\n",
       "146322  999999998651280              CPU_free_pct  ZJ-002-056  1590527940000   \n",
       "146323  999999998650680              CPU_free_pct  ZJ-002-056  1590527940000   \n",
       "146324  999999998651100             MEM_real_util  ZJ-002-053  1590527940000   \n",
       "146325  999999998650980              CPU_free_pct  ZJ-002-056  1590527940000   \n",
       "146326  999999996381601              CPU_free_pct  ZJ-002-056  1590527941000   \n",
       "...                 ...                       ...         ...            ...   \n",
       "558272  999999996432240               Disk_rd_ios  ZJ-001-098  1590529260000   \n",
       "558273         65435640              Disk_io_util  ZJ-001-125  1590529260000   \n",
       "558274         65439900              Disk_io_util  ZJ-001-125  1590529260000   \n",
       "558275         63308940  Outgoing_network_traffic  ZJ-001-072  1590529260000   \n",
       "558276  999999996430740                Send_total  ZJ-001-074  1590529260000   \n",
       "\n",
       "            value cmdb_id  \n",
       "146322  98.133749  db_008  \n",
       "146323  99.401682  db_001  \n",
       "146324  80.450000  db_007  \n",
       "146325  98.802366  db_003  \n",
       "146326  97.540565  db_009  \n",
       "...           ...     ...  \n",
       "558272   0.000000  os_007  \n",
       "558273   0.000000  os_020  \n",
       "558274   2.000000  os_012  \n",
       "558275   0.021174  os_022  \n",
       "558276   0.000317  os_006  \n",
       "\n",
       "[36375 rows x 6 columns]"
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>itemid</th>\n      <th>name</th>\n      <th>bomc_id</th>\n      <th>timestamp</th>\n      <th>value</th>\n      <th>cmdb_id</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>146322</th>\n      <td>999999998651280</td>\n      <td>CPU_free_pct</td>\n      <td>ZJ-002-056</td>\n      <td>1590527940000</td>\n      <td>98.133749</td>\n      <td>db_008</td>\n    </tr>\n    <tr>\n      <th>146323</th>\n      <td>999999998650680</td>\n      <td>CPU_free_pct</td>\n      <td>ZJ-002-056</td>\n      <td>1590527940000</td>\n      <td>99.401682</td>\n      <td>db_001</td>\n    </tr>\n    <tr>\n      <th>146324</th>\n      <td>999999998651100</td>\n      <td>MEM_real_util</td>\n      <td>ZJ-002-053</td>\n      <td>1590527940000</td>\n      <td>80.450000</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>146325</th>\n      <td>999999998650980</td>\n      <td>CPU_free_pct</td>\n      <td>ZJ-002-056</td>\n      <td>1590527940000</td>\n      <td>98.802366</td>\n      <td>db_003</td>\n    </tr>\n    <tr>\n      <th>146326</th>\n      <td>999999996381601</td>\n      <td>CPU_free_pct</td>\n      <td>ZJ-002-056</td>\n      <td>1590527941000</td>\n      <td>97.540565</td>\n      <td>db_009</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>558272</th>\n      <td>999999996432240</td>\n      <td>Disk_rd_ios</td>\n      <td>ZJ-001-098</td>\n      <td>1590529260000</td>\n      <td>0.000000</td>\n      <td>os_007</td>\n    </tr>\n    <tr>\n      <th>558273</th>\n      <td>65435640</td>\n      <td>Disk_io_util</td>\n      <td>ZJ-001-125</td>\n      <td>1590529260000</td>\n      <td>0.000000</td>\n      <td>os_020</td>\n    </tr>\n    <tr>\n      <th>558274</th>\n      <td>65439900</td>\n      <td>Disk_io_util</td>\n      <td>ZJ-001-125</td>\n      <td>1590529260000</td>\n      <td>2.000000</td>\n      <td>os_012</td>\n    </tr>\n    <tr>\n      <th>558275</th>\n      <td>63308940</td>\n      <td>Outgoing_network_traffic</td>\n      <td>ZJ-001-072</td>\n      <td>1590529260000</td>\n      <td>0.021174</td>\n      <td>os_022</td>\n    </tr>\n    <tr>\n      <th>558276</th>\n      <td>999999996430740</td>\n      <td>Send_total</td>\n      <td>ZJ-001-074</td>\n      <td>1590529260000</td>\n      <td>0.000317</td>\n      <td>os_006</td>\n    </tr>\n  </tbody>\n</table>\n<p>36375 rows × 6 columns</p>\n</div>"
     },
     "metadata": {},
     "execution_count": 4
    }
   ],
   "source": [
    "anomaly_time = 1590529140000\n",
    "# 1590430140000 db 007\n",
    "# 1590431940000 docker 008\n",
    "# 1590433740000 os 21\n",
    "# 1590435540000 os 18\n",
    "df = df[(df.timestamp >= (anomaly_time-1200000)) & (df.timestamp <= (anomaly_time + 120000))]\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "output_type": "error",
     "ename": "NameError",
     "evalue": "name 'df' is not defined",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-2-fc0d6f570cc5>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0msave_path\u001b[0m \u001b[1;33m=\u001b[0m\u001b[1;34m'D:\\\\THU Studies\\\\Advance Network Management\\\\Project\\\\Anomaly-detection\\\\local_data\\\\noJDBC\\\\'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mto_csv\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msave_path\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;34m'kpi_data_527_os21_sentque.csv'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mindex\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mFalse\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'df' is not defined"
     ]
    }
   ],
   "source": [
    "save_path ='D:\\\\THU Studies\\\\Advance Network Management\\\\Project\\\\Anomaly-detection\\\\local_data\\\\noJDBC\\\\'\n",
    "df.to_csv(save_path+'kpi_data_527_os21_sentque.csv', index = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "['C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Trace\\\\trace_csf.csv',\n",
       " 'C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Trace\\\\trace_fly_remote.csv',\n",
       " 'C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Trace\\\\trace_local.csv',\n",
       " 'C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Trace\\\\trace_osb.csv',\n",
       " 'C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Trace\\\\trace_remote_process.csv']"
      ]
     },
     "metadata": {},
     "execution_count": 2
    }
   ],
   "source": [
    "path = \"C:\\\\Users\\\\Henry\\\\Documents\\\\data\\\\2020_05_27\\\\Trace\\\\\"\n",
    "all_files = glob.glob(path + \"*.csv\")\n",
    "all_files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfs = []\n",
    "for filename in all_files:\n",
    "    df = pd.read_csv(filename, index_col=None)\n",
    "    dfs.append(df)\n",
    "# df = pd.concat(dfs, axis=0, ignore_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "array(['docker_002', 'docker_005', 'docker_001', 'docker_006',\n",
       "       'docker_003', 'docker_007', 'docker_008', 'docker_004'],\n",
       "      dtype=object)"
      ]
     },
     "metadata": {},
     "execution_count": 24
    }
   ],
   "source": [
    "df.cmdb_id.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "for df in dfs:\n",
    "    if df['callType'].iloc[0]=='JDBC' or df['callType'].iloc[0]=='LOCAL':\n",
    "        df['serviceName'] = df['dsName']\n",
    "    elif df['callType'].iloc[0]=='RemoteProcess' or df['callType'].iloc[0]=='OSB':\n",
    "        df['serviceName'] = df['cmdb_id']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.concat(dfs, axis=0, ignore_index=True)\n",
    "# df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "  callType      startTime  elapsedTime  success               traceId  \\\n",
       "0      CSF  1590508800030       2308.0     True  73271d2485849471c76f   \n",
       "1      CSF  1590508800033        251.0     True  73271854e26857b1c76f   \n",
       "2      CSF  1590508800034        884.0     True  73271c5c4a2367b1c76f   \n",
       "3      CSF  1590508800035        554.0     True  732712b99f4257b1c76f   \n",
       "4      CSF  1590508800036        882.0     True  7327133bf44367f1c76f   \n",
       "\n",
       "                     id                   pid cmdb_id serviceName  \n",
       "0  7327121d411594e1c76f  7327120256949471c76f  os_022     csf_001  \n",
       "1  73271e1ee0985712c76f  73271e287b7857b1c76f  os_022     csf_001  \n",
       "2  732717e236736722c76f  732714be573367b1c76f  os_022     csf_001  \n",
       "3  73271bc681725732c76f  732714a7505257b1c76f  os_022     csf_001  \n",
       "4  732711fddf936742c76f  7327100cbd5367f1c76f  os_022     csf_001  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>callType</th>\n      <th>startTime</th>\n      <th>elapsedTime</th>\n      <th>success</th>\n      <th>traceId</th>\n      <th>id</th>\n      <th>pid</th>\n      <th>cmdb_id</th>\n      <th>serviceName</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>CSF</td>\n      <td>1590508800030</td>\n      <td>2308.0</td>\n      <td>True</td>\n      <td>73271d2485849471c76f</td>\n      <td>7327121d411594e1c76f</td>\n      <td>7327120256949471c76f</td>\n      <td>os_022</td>\n      <td>csf_001</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>CSF</td>\n      <td>1590508800033</td>\n      <td>251.0</td>\n      <td>True</td>\n      <td>73271854e26857b1c76f</td>\n      <td>73271e1ee0985712c76f</td>\n      <td>73271e287b7857b1c76f</td>\n      <td>os_022</td>\n      <td>csf_001</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>CSF</td>\n      <td>1590508800034</td>\n      <td>884.0</td>\n      <td>True</td>\n      <td>73271c5c4a2367b1c76f</td>\n      <td>732717e236736722c76f</td>\n      <td>732714be573367b1c76f</td>\n      <td>os_022</td>\n      <td>csf_001</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>CSF</td>\n      <td>1590508800035</td>\n      <td>554.0</td>\n      <td>True</td>\n      <td>732712b99f4257b1c76f</td>\n      <td>73271bc681725732c76f</td>\n      <td>732714a7505257b1c76f</td>\n      <td>os_022</td>\n      <td>csf_001</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>CSF</td>\n      <td>1590508800036</td>\n      <td>882.0</td>\n      <td>True</td>\n      <td>7327133bf44367f1c76f</td>\n      <td>732711fddf936742c76f</td>\n      <td>7327100cbd5367f1c76f</td>\n      <td>os_022</td>\n      <td>csf_001</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "source": [
    "df = df.drop('dsName', axis=1, index=None)\n",
    "# df = df.drop(['path'], axis=1)\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "array(['os_022', 'docker_002', 'docker_001', 'os_021', 'docker_003',\n",
       "       'docker_004', nan, 'docker_008', 'docker_007', 'docker_005',\n",
       "       'docker_006'], dtype=object)"
      ]
     },
     "metadata": {},
     "execution_count": 9
    }
   ],
   "source": [
    "df.cmdb_id.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.dropna(inplace = True, axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "anomaly_time = 1590529140000\n",
    "# 1590430140000 db 007\n",
    "# 1590431940000 docker 008\n",
    "# 1590433740000 os 21\n",
    "df = df[(df.startTime >= (anomaly_time-1200000)) & (df.startTime <= (anomaly_time + 120000))]\n",
    "# df.to_csv(save_path + 'trace_data_527_os21_sentque.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "       callType      startTime  elapsedTime  success               traceId  \\\n",
       "710638      CSF  1590527940030        445.0     True  9327134ba800267b98a1   \n",
       "710639      CSF  1590527940030        489.0     True  93271c735781637b98a1   \n",
       "710640      CSF  1590527940031        515.0     True  93271790d84263ab98a1   \n",
       "710641      CSF  1590527940032       3274.0     True  93271cabdf43166b98a1   \n",
       "710642      CSF  1590527940033       3273.0     True  93271dde5e63167b98a1   \n",
       "\n",
       "                          id                   pid cmdb_id serviceName  \n",
       "710638  93271f208f3026eb98a1  932710c86210267b98a1  os_022     csf_001  \n",
       "710639  93271b84437263eb98a1  932717e9e191637b98a1  os_022     csf_001  \n",
       "710640  93271ceacc9263fb98a1  932716cc5d5263ab98a1  os_022     csf_001  \n",
       "710641  93271c077693160c98a1  932715ad1a53166b98a1  os_022     csf_001  \n",
       "710642  93271600c614161c98a1  93271ffd0c73167b98a1  os_022     csf_001  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>callType</th>\n      <th>startTime</th>\n      <th>elapsedTime</th>\n      <th>success</th>\n      <th>traceId</th>\n      <th>id</th>\n      <th>pid</th>\n      <th>cmdb_id</th>\n      <th>serviceName</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>710638</th>\n      <td>CSF</td>\n      <td>1590527940030</td>\n      <td>445.0</td>\n      <td>True</td>\n      <td>9327134ba800267b98a1</td>\n      <td>93271f208f3026eb98a1</td>\n      <td>932710c86210267b98a1</td>\n      <td>os_022</td>\n      <td>csf_001</td>\n    </tr>\n    <tr>\n      <th>710639</th>\n      <td>CSF</td>\n      <td>1590527940030</td>\n      <td>489.0</td>\n      <td>True</td>\n      <td>93271c735781637b98a1</td>\n      <td>93271b84437263eb98a1</td>\n      <td>932717e9e191637b98a1</td>\n      <td>os_022</td>\n      <td>csf_001</td>\n    </tr>\n    <tr>\n      <th>710640</th>\n      <td>CSF</td>\n      <td>1590527940031</td>\n      <td>515.0</td>\n      <td>True</td>\n      <td>93271790d84263ab98a1</td>\n      <td>93271ceacc9263fb98a1</td>\n      <td>932716cc5d5263ab98a1</td>\n      <td>os_022</td>\n      <td>csf_001</td>\n    </tr>\n    <tr>\n      <th>710641</th>\n      <td>CSF</td>\n      <td>1590527940032</td>\n      <td>3274.0</td>\n      <td>True</td>\n      <td>93271cabdf43166b98a1</td>\n      <td>93271c077693160c98a1</td>\n      <td>932715ad1a53166b98a1</td>\n      <td>os_022</td>\n      <td>csf_001</td>\n    </tr>\n    <tr>\n      <th>710642</th>\n      <td>CSF</td>\n      <td>1590527940033</td>\n      <td>3273.0</td>\n      <td>True</td>\n      <td>93271dde5e63167b98a1</td>\n      <td>93271600c614161c98a1</td>\n      <td>93271ffd0c73167b98a1</td>\n      <td>os_022</td>\n      <td>csf_001</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 10
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "ldf = df[df.callType=='LOCAL']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "        callType      startTime  elapsedTime  success               traceId  \\\n",
       "2315590    LOCAL  1590517473980          5.0    False  8327148d408633b16da7   \n",
       "2315595    LOCAL  1590517474028         89.0    False  8327199c5b6533a32da7   \n",
       "2315651    LOCAL  1590517474202         91.0    False  832711f66f4788551da7   \n",
       "2315653    LOCAL  1590517474204         91.0    False  832716f8604788c81da7   \n",
       "2315657    LOCAL  1590517474221         95.0    False  83271e4ce54923404da7   \n",
       "2315676    LOCAL  1590517474273         85.0    False  832719afb360331e6da7   \n",
       "2315703    LOCAL  1590517474376         80.0    False  832717c6728143cd6da7   \n",
       "2315704    LOCAL  1590517474377         81.0    False  8327192b3221339f6da7   \n",
       "2315719    LOCAL  1590517474425          4.0    False  83271c818c0033405da7   \n",
       "2315743    LOCAL  1590517474497         17.0    False  8327190da70888528da7   \n",
       "2315768    LOCAL  1590517474574          4.0    False  832716c02a0579767da7   \n",
       "2315776    LOCAL  1590517474601         93.0    False  8327137c3a2788e62da7   \n",
       "2315820    LOCAL  1590517474716          6.0    False  832712ef7d68887b8da7   \n",
       "2315839    LOCAL  1590517474763          4.0    False  83271d27148679298da7   \n",
       "2315841    LOCAL  1590517474765          3.0    False  832710e0a32679e68da7   \n",
       "2315867    LOCAL  1590517474832          4.0    False  83271b86f46888be8da7   \n",
       "2315879    LOCAL  1590517474918          5.0    False  83271825986579158da7   \n",
       "2315892    LOCAL  1590517474933         77.0    False  832711cddb4812139da7   \n",
       "2315962    LOCAL  1590517475232          6.0    False  832715378f2988f3ada7   \n",
       "2315963    LOCAL  1590517475233          3.0    False  832714ed6f091220ada7   \n",
       "2315972    LOCAL  1590517475298          8.0    False  83271cfd0a87885b5da7   \n",
       "2316000    LOCAL  1590517475329          5.0    False  83271e72c1473397ada7   \n",
       "2316003    LOCAL  1590517475333          4.0    False  832717fe6f898849ada7   \n",
       "2316062    LOCAL  1590517475506          4.0    False  83271e2683083302cda7   \n",
       "2316064    LOCAL  1590517475507          4.0    False  832714b5a34243e1cda7   \n",
       "2316101    LOCAL  1590517475617          4.0    False  8327154be96912c0cda7   \n",
       "2316108    LOCAL  1590517475628          5.0    False  832714934a6988d0cda7   \n",
       "2316124    LOCAL  1590517475699          5.0    False  83271fa16687129b8da7   \n",
       "2316133    LOCAL  1590517475706          6.0    False  83271c368768331ecda7   \n",
       "2316163    LOCAL  1590517475793          6.0    False  8327110842293314dda7   \n",
       "2316184    LOCAL  1590517475808          3.0    False  83271d152820982ecda7   \n",
       "2316221    LOCAL  1590517475929          6.0    False  83271f6580434369dda7   \n",
       "2316244    LOCAL  1590517475982          4.0    False  83271050f7034359dda7   \n",
       "2316261    LOCAL  1590517476038          5.0    False  8327142c538233afdda7   \n",
       "2316301    LOCAL  1590517476155          3.0    False  832712a63e477997eda7   \n",
       "2316323    LOCAL  1590517476195          6.0    False  83271105124888fb9da7   \n",
       "2316324    LOCAL  1590517476196          7.0    False  83271582312988be8da7   \n",
       "2316328    LOCAL  1590517476259          7.0    False  83271223ef81334fdda7   \n",
       "2316329    LOCAL  1590517476260          4.0    False  83271f7cb522337fdda7   \n",
       "2316337    LOCAL  1590517476301          5.0    False  832712ef080988fdada7   \n",
       "2316361    LOCAL  1590517476401          6.0    False  832719048a898854ada7   \n",
       "2316420    LOCAL  1590517476529          4.0    False  8327164e2280983dfda7   \n",
       "2316425    LOCAL  1590517476538         75.0    False  83271b6f1d60980dfda7   \n",
       "2316438    LOCAL  1590517476570          5.0    False  832711adff24435eeda7   \n",
       "2316444    LOCAL  1590517476577         81.0    False  83271f0b150879feeda7   \n",
       "2316464    LOCAL  1590517476632          5.0    False  8327179f2f61987efda7   \n",
       "2316471    LOCAL  1590517476672          4.0    False  8327125f61687965fda7   \n",
       "2316506    LOCAL  1590517476775          4.0    False  83271a56fa63336efda7   \n",
       "2316525    LOCAL  1590517476797          5.0    False  832718ace82979621ea7   \n",
       "2316526    LOCAL  1590517476799         97.0    False  832710bd2c4098eccda7   \n",
       "2316558    LOCAL  1590517476920          4.0    False  83271c1b800198541ea7   \n",
       "2316563    LOCAL  1590517476928          4.0    False  832716399e6198451ea7   \n",
       "2316579    LOCAL  1590517477031          4.0    False  832715bfb82298c61ea7   \n",
       "2316606    LOCAL  1590517477209          4.0    False  83271754dc4198262ea7   \n",
       "2316665    LOCAL  1590517477703          6.0    False  83271460ce8022411ea7   \n",
       "2316672    LOCAL  1590517477714        186.0    False  83271f33272022050ea7   \n",
       "2316679    LOCAL  1590517477999          5.0    False  83271e7a984122e21ea7   \n",
       "2316706    LOCAL  1590517478114         82.0    False  832717527302222f1ea7   \n",
       "2316711    LOCAL  1590517478202          5.0    False  83271cce070298a51ea7   \n",
       "2316712    LOCAL  1590517478204          4.0    False  83271df45d8098ed1ea7   \n",
       "\n",
       "                           id                   pid     cmdb_id serviceName  \n",
       "2315590  83271257910722cb6da7  832712f90d0912226da7  docker_002      db_007  \n",
       "2315595  83271ab60f7719ce6da7  832710f8207098692da7  docker_001      db_007  \n",
       "2315651  83271656703197a97da7  83271a1bb69257b51da7  docker_003      db_007  \n",
       "2315653  83271a05dd0297c97da7  83271cddf793576b1da7  docker_003      db_007  \n",
       "2315657  832712ae873329da7da7  83271bde727698524da7  docker_001      db_007  \n",
       "2315676  83271b430754421e7da7  83271040c167227e6da7  docker_002      db_007  \n",
       "2315703  83271ce2824252848da7  83271d7eae27224e6da7  docker_002      db_007  \n",
       "2315704  83271db0546252948da7  83271c65f78722407da7  docker_002      db_007  \n",
       "2315719  832711ca467039978da7  83271259427309155da7  docker_001      db_007  \n",
       "2315743  83271ff0f472151c8da7  83271eb8c15405f28da7  docker_004      db_007  \n",
       "2315768  832714525a4162e09da7  832711c2f70032c67da7  docker_002      db_007  \n",
       "2315776  83271e46077797929da7  832717f2a65857e72da7  docker_003      db_007  \n",
       "2315820  832715656b7225c99da7  8327128bfb0215eb8da7  docker_004      db_007  \n",
       "2315839  8327121e725572bc9da7  832713be780352b98da7  docker_002      db_007  \n",
       "2315841  83271be9f72672dc9da7  83271275f08252898da7  docker_002      db_007  \n",
       "2315867  8327119923503501ada7  832711728c53150f8da7  docker_004      db_007  \n",
       "2315879  83271702ca983966ada7  83271ed3810829178da7  docker_001      db_007  \n",
       "2315892  832717c42b383557ada7  83271c81187415e39da7  docker_004      db_007  \n",
       "2315962  832718c0d954550abda7  832717c9309135e5ada7  docker_004      db_007  \n",
       "2315963  83271aa49374551abda7  83271cf161682580ada7  docker_004      db_007  \n",
       "2315972  83271e25b680182ebda7  83271ed5f46087206da7  docker_003      db_007  \n",
       "2316000  83271dc866174910cda7  83271b616b1939a8ada7  docker_001      db_007  \n",
       "2316003  832710a729716550cda7  8327175c1558353cada7  docker_004      db_007  \n",
       "2316062  8327103c6b35592bcda7  8327102f1d374962cda7  docker_001      db_007  \n",
       "2316064  83271df21644823bcda7  832716868a467232cda7  docker_002      db_007  \n",
       "2316101  83271dca6a067512dda7  832710045f126531cda7  docker_004      db_007  \n",
       "2316108  83271c80387875c2dda7  83271fda58916521cda7  docker_004      db_007  \n",
       "2316124  832718bc58442837dda7  83271df42165970c8da7  docker_003      db_007  \n",
       "2316133  832710236f7369a7dda7  832712a3367559becda7  docker_001      db_007  \n",
       "2316163  83271b38a743921ddda7  83271e55b7648284dda7  docker_002      db_007  \n",
       "2316184  83271290c936850edda7  8327189f1860756ecda7  docker_004      db_007  \n",
       "2316221  83271dc03f927995eda7  8327144cf09369e9dda7  docker_001      db_007  \n",
       "2316244  83271b6c978203e8eda7  8327103d7b6582b9dda7  docker_002      db_007  \n",
       "2316261  83271218e370896ceda7  83271138d4946900eda7  docker_001      db_007  \n",
       "2316301  8327155cc23889b3fda7  832710c6e0337948eda7  docker_001      db_007  \n",
       "2316323  832717dc46593836fda7  83271d408009978e9da7  docker_003      db_007  \n",
       "2316324  8327116488793846fda7  8327119bdd8697229da7  docker_003      db_007  \n",
       "2316328  832714865568133afda7  8327105bca839221eda7  docker_002      db_007  \n",
       "2316329  832719302888134afda7  8327113c26049221eda7  docker_002      db_007  \n",
       "2316337  832713d4904348dcfda7  8327114579050851bda7  docker_003      db_007  \n",
       "2316361  832713689c3648130ea7  832717f2324108d4ada7  docker_003      db_007  \n",
       "2316420  83271eba5a91061b0ea7  832718f23776859dfda7  docker_004      db_007  \n",
       "2316425  8327100bf39306ab0ea7  832718a98856856dfda7  docker_004      db_007  \n",
       "2316438  832711e8ed1733ad0ea7  832716c6794303beeda7  docker_002      db_007  \n",
       "2316444  83271e79bb89331e0ea7  832712044304036feda7  docker_002      db_007  \n",
       "2316464  83271851019016811ea7  832711de6b7785befda7  docker_004      db_007  \n",
       "2316471  8327147f360343041ea7  83271b17f118131afda7  docker_002      db_007  \n",
       "2316506  83271de4db00537a1ea7  83271697748913500ea7  docker_002      db_007  \n",
       "2316525  83271e5e7a9699db1ea7  83271a29cd9889d21ea7  docker_001      db_007  \n",
       "2316526  832713d43b3558fb1ea7  83271108be7918a0dda7  docker_003      db_007  \n",
       "2316558  8327125e203626832ea7  8327142c431116c41ea7  docker_004      db_007  \n",
       "2316563  83271d07985826042ea7  832711f14a5116e51ea7  docker_004      db_007  \n",
       "2316579  83271c005c16367a2ea7  83271a440e3216071ea7  docker_004      db_007  \n",
       "2316606  832717ea007346953ea7  832712f8ce5926292ea7  docker_004      db_007  \n",
       "2316665  8327184f0a7878745ea7  83271dbd7c1158551ea7  docker_003      db_007  \n",
       "2316672  83271454402288255ea7  83271d1df00748d80ea7  docker_003      db_007  \n",
       "2316679  83271547136688f66ea7  83271064f56158551ea7  docker_003      db_007  \n",
       "2316706  83271e970f40092e6ea7  83271d80887558e12ea7  docker_003      db_007  \n",
       "2316711  83271341cb6209a37ea7  832713faaa2458f51ea7  docker_003      db_007  \n",
       "2316712  8327115a2b1309c37ea7  8327111f799558e12ea7  docker_003      db_007  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>callType</th>\n      <th>startTime</th>\n      <th>elapsedTime</th>\n      <th>success</th>\n      <th>traceId</th>\n      <th>id</th>\n      <th>pid</th>\n      <th>cmdb_id</th>\n      <th>serviceName</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2315590</th>\n      <td>LOCAL</td>\n      <td>1590517473980</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>8327148d408633b16da7</td>\n      <td>83271257910722cb6da7</td>\n      <td>832712f90d0912226da7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315595</th>\n      <td>LOCAL</td>\n      <td>1590517474028</td>\n      <td>89.0</td>\n      <td>False</td>\n      <td>8327199c5b6533a32da7</td>\n      <td>83271ab60f7719ce6da7</td>\n      <td>832710f8207098692da7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315651</th>\n      <td>LOCAL</td>\n      <td>1590517474202</td>\n      <td>91.0</td>\n      <td>False</td>\n      <td>832711f66f4788551da7</td>\n      <td>83271656703197a97da7</td>\n      <td>83271a1bb69257b51da7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315653</th>\n      <td>LOCAL</td>\n      <td>1590517474204</td>\n      <td>91.0</td>\n      <td>False</td>\n      <td>832716f8604788c81da7</td>\n      <td>83271a05dd0297c97da7</td>\n      <td>83271cddf793576b1da7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315657</th>\n      <td>LOCAL</td>\n      <td>1590517474221</td>\n      <td>95.0</td>\n      <td>False</td>\n      <td>83271e4ce54923404da7</td>\n      <td>832712ae873329da7da7</td>\n      <td>83271bde727698524da7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315676</th>\n      <td>LOCAL</td>\n      <td>1590517474273</td>\n      <td>85.0</td>\n      <td>False</td>\n      <td>832719afb360331e6da7</td>\n      <td>83271b430754421e7da7</td>\n      <td>83271040c167227e6da7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315703</th>\n      <td>LOCAL</td>\n      <td>1590517474376</td>\n      <td>80.0</td>\n      <td>False</td>\n      <td>832717c6728143cd6da7</td>\n      <td>83271ce2824252848da7</td>\n      <td>83271d7eae27224e6da7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315704</th>\n      <td>LOCAL</td>\n      <td>1590517474377</td>\n      <td>81.0</td>\n      <td>False</td>\n      <td>8327192b3221339f6da7</td>\n      <td>83271db0546252948da7</td>\n      <td>83271c65f78722407da7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315719</th>\n      <td>LOCAL</td>\n      <td>1590517474425</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>83271c818c0033405da7</td>\n      <td>832711ca467039978da7</td>\n      <td>83271259427309155da7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315743</th>\n      <td>LOCAL</td>\n      <td>1590517474497</td>\n      <td>17.0</td>\n      <td>False</td>\n      <td>8327190da70888528da7</td>\n      <td>83271ff0f472151c8da7</td>\n      <td>83271eb8c15405f28da7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315768</th>\n      <td>LOCAL</td>\n      <td>1590517474574</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>832716c02a0579767da7</td>\n      <td>832714525a4162e09da7</td>\n      <td>832711c2f70032c67da7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315776</th>\n      <td>LOCAL</td>\n      <td>1590517474601</td>\n      <td>93.0</td>\n      <td>False</td>\n      <td>8327137c3a2788e62da7</td>\n      <td>83271e46077797929da7</td>\n      <td>832717f2a65857e72da7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315820</th>\n      <td>LOCAL</td>\n      <td>1590517474716</td>\n      <td>6.0</td>\n      <td>False</td>\n      <td>832712ef7d68887b8da7</td>\n      <td>832715656b7225c99da7</td>\n      <td>8327128bfb0215eb8da7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315839</th>\n      <td>LOCAL</td>\n      <td>1590517474763</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>83271d27148679298da7</td>\n      <td>8327121e725572bc9da7</td>\n      <td>832713be780352b98da7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315841</th>\n      <td>LOCAL</td>\n      <td>1590517474765</td>\n      <td>3.0</td>\n      <td>False</td>\n      <td>832710e0a32679e68da7</td>\n      <td>83271be9f72672dc9da7</td>\n      <td>83271275f08252898da7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315867</th>\n      <td>LOCAL</td>\n      <td>1590517474832</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>83271b86f46888be8da7</td>\n      <td>8327119923503501ada7</td>\n      <td>832711728c53150f8da7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315879</th>\n      <td>LOCAL</td>\n      <td>1590517474918</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>83271825986579158da7</td>\n      <td>83271702ca983966ada7</td>\n      <td>83271ed3810829178da7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315892</th>\n      <td>LOCAL</td>\n      <td>1590517474933</td>\n      <td>77.0</td>\n      <td>False</td>\n      <td>832711cddb4812139da7</td>\n      <td>832717c42b383557ada7</td>\n      <td>83271c81187415e39da7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315962</th>\n      <td>LOCAL</td>\n      <td>1590517475232</td>\n      <td>6.0</td>\n      <td>False</td>\n      <td>832715378f2988f3ada7</td>\n      <td>832718c0d954550abda7</td>\n      <td>832717c9309135e5ada7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315963</th>\n      <td>LOCAL</td>\n      <td>1590517475233</td>\n      <td>3.0</td>\n      <td>False</td>\n      <td>832714ed6f091220ada7</td>\n      <td>83271aa49374551abda7</td>\n      <td>83271cf161682580ada7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2315972</th>\n      <td>LOCAL</td>\n      <td>1590517475298</td>\n      <td>8.0</td>\n      <td>False</td>\n      <td>83271cfd0a87885b5da7</td>\n      <td>83271e25b680182ebda7</td>\n      <td>83271ed5f46087206da7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316000</th>\n      <td>LOCAL</td>\n      <td>1590517475329</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>83271e72c1473397ada7</td>\n      <td>83271dc866174910cda7</td>\n      <td>83271b616b1939a8ada7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316003</th>\n      <td>LOCAL</td>\n      <td>1590517475333</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>832717fe6f898849ada7</td>\n      <td>832710a729716550cda7</td>\n      <td>8327175c1558353cada7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316062</th>\n      <td>LOCAL</td>\n      <td>1590517475506</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>83271e2683083302cda7</td>\n      <td>8327103c6b35592bcda7</td>\n      <td>8327102f1d374962cda7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316064</th>\n      <td>LOCAL</td>\n      <td>1590517475507</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>832714b5a34243e1cda7</td>\n      <td>83271df21644823bcda7</td>\n      <td>832716868a467232cda7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316101</th>\n      <td>LOCAL</td>\n      <td>1590517475617</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>8327154be96912c0cda7</td>\n      <td>83271dca6a067512dda7</td>\n      <td>832710045f126531cda7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316108</th>\n      <td>LOCAL</td>\n      <td>1590517475628</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>832714934a6988d0cda7</td>\n      <td>83271c80387875c2dda7</td>\n      <td>83271fda58916521cda7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316124</th>\n      <td>LOCAL</td>\n      <td>1590517475699</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>83271fa16687129b8da7</td>\n      <td>832718bc58442837dda7</td>\n      <td>83271df42165970c8da7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316133</th>\n      <td>LOCAL</td>\n      <td>1590517475706</td>\n      <td>6.0</td>\n      <td>False</td>\n      <td>83271c368768331ecda7</td>\n      <td>832710236f7369a7dda7</td>\n      <td>832712a3367559becda7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316163</th>\n      <td>LOCAL</td>\n      <td>1590517475793</td>\n      <td>6.0</td>\n      <td>False</td>\n      <td>8327110842293314dda7</td>\n      <td>83271b38a743921ddda7</td>\n      <td>83271e55b7648284dda7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316184</th>\n      <td>LOCAL</td>\n      <td>1590517475808</td>\n      <td>3.0</td>\n      <td>False</td>\n      <td>83271d152820982ecda7</td>\n      <td>83271290c936850edda7</td>\n      <td>8327189f1860756ecda7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316221</th>\n      <td>LOCAL</td>\n      <td>1590517475929</td>\n      <td>6.0</td>\n      <td>False</td>\n      <td>83271f6580434369dda7</td>\n      <td>83271dc03f927995eda7</td>\n      <td>8327144cf09369e9dda7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316244</th>\n      <td>LOCAL</td>\n      <td>1590517475982</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>83271050f7034359dda7</td>\n      <td>83271b6c978203e8eda7</td>\n      <td>8327103d7b6582b9dda7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316261</th>\n      <td>LOCAL</td>\n      <td>1590517476038</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>8327142c538233afdda7</td>\n      <td>83271218e370896ceda7</td>\n      <td>83271138d4946900eda7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316301</th>\n      <td>LOCAL</td>\n      <td>1590517476155</td>\n      <td>3.0</td>\n      <td>False</td>\n      <td>832712a63e477997eda7</td>\n      <td>8327155cc23889b3fda7</td>\n      <td>832710c6e0337948eda7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316323</th>\n      <td>LOCAL</td>\n      <td>1590517476195</td>\n      <td>6.0</td>\n      <td>False</td>\n      <td>83271105124888fb9da7</td>\n      <td>832717dc46593836fda7</td>\n      <td>83271d408009978e9da7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316324</th>\n      <td>LOCAL</td>\n      <td>1590517476196</td>\n      <td>7.0</td>\n      <td>False</td>\n      <td>83271582312988be8da7</td>\n      <td>8327116488793846fda7</td>\n      <td>8327119bdd8697229da7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316328</th>\n      <td>LOCAL</td>\n      <td>1590517476259</td>\n      <td>7.0</td>\n      <td>False</td>\n      <td>83271223ef81334fdda7</td>\n      <td>832714865568133afda7</td>\n      <td>8327105bca839221eda7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316329</th>\n      <td>LOCAL</td>\n      <td>1590517476260</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>83271f7cb522337fdda7</td>\n      <td>832719302888134afda7</td>\n      <td>8327113c26049221eda7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316337</th>\n      <td>LOCAL</td>\n      <td>1590517476301</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>832712ef080988fdada7</td>\n      <td>832713d4904348dcfda7</td>\n      <td>8327114579050851bda7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316361</th>\n      <td>LOCAL</td>\n      <td>1590517476401</td>\n      <td>6.0</td>\n      <td>False</td>\n      <td>832719048a898854ada7</td>\n      <td>832713689c3648130ea7</td>\n      <td>832717f2324108d4ada7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316420</th>\n      <td>LOCAL</td>\n      <td>1590517476529</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>8327164e2280983dfda7</td>\n      <td>83271eba5a91061b0ea7</td>\n      <td>832718f23776859dfda7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316425</th>\n      <td>LOCAL</td>\n      <td>1590517476538</td>\n      <td>75.0</td>\n      <td>False</td>\n      <td>83271b6f1d60980dfda7</td>\n      <td>8327100bf39306ab0ea7</td>\n      <td>832718a98856856dfda7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316438</th>\n      <td>LOCAL</td>\n      <td>1590517476570</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>832711adff24435eeda7</td>\n      <td>832711e8ed1733ad0ea7</td>\n      <td>832716c6794303beeda7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316444</th>\n      <td>LOCAL</td>\n      <td>1590517476577</td>\n      <td>81.0</td>\n      <td>False</td>\n      <td>83271f0b150879feeda7</td>\n      <td>83271e79bb89331e0ea7</td>\n      <td>832712044304036feda7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316464</th>\n      <td>LOCAL</td>\n      <td>1590517476632</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>8327179f2f61987efda7</td>\n      <td>83271851019016811ea7</td>\n      <td>832711de6b7785befda7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316471</th>\n      <td>LOCAL</td>\n      <td>1590517476672</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>8327125f61687965fda7</td>\n      <td>8327147f360343041ea7</td>\n      <td>83271b17f118131afda7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316506</th>\n      <td>LOCAL</td>\n      <td>1590517476775</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>83271a56fa63336efda7</td>\n      <td>83271de4db00537a1ea7</td>\n      <td>83271697748913500ea7</td>\n      <td>docker_002</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316525</th>\n      <td>LOCAL</td>\n      <td>1590517476797</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>832718ace82979621ea7</td>\n      <td>83271e5e7a9699db1ea7</td>\n      <td>83271a29cd9889d21ea7</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316526</th>\n      <td>LOCAL</td>\n      <td>1590517476799</td>\n      <td>97.0</td>\n      <td>False</td>\n      <td>832710bd2c4098eccda7</td>\n      <td>832713d43b3558fb1ea7</td>\n      <td>83271108be7918a0dda7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316558</th>\n      <td>LOCAL</td>\n      <td>1590517476920</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>83271c1b800198541ea7</td>\n      <td>8327125e203626832ea7</td>\n      <td>8327142c431116c41ea7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316563</th>\n      <td>LOCAL</td>\n      <td>1590517476928</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>832716399e6198451ea7</td>\n      <td>83271d07985826042ea7</td>\n      <td>832711f14a5116e51ea7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316579</th>\n      <td>LOCAL</td>\n      <td>1590517477031</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>832715bfb82298c61ea7</td>\n      <td>83271c005c16367a2ea7</td>\n      <td>83271a440e3216071ea7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316606</th>\n      <td>LOCAL</td>\n      <td>1590517477209</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>83271754dc4198262ea7</td>\n      <td>832717ea007346953ea7</td>\n      <td>832712f8ce5926292ea7</td>\n      <td>docker_004</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316665</th>\n      <td>LOCAL</td>\n      <td>1590517477703</td>\n      <td>6.0</td>\n      <td>False</td>\n      <td>83271460ce8022411ea7</td>\n      <td>8327184f0a7878745ea7</td>\n      <td>83271dbd7c1158551ea7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316672</th>\n      <td>LOCAL</td>\n      <td>1590517477714</td>\n      <td>186.0</td>\n      <td>False</td>\n      <td>83271f33272022050ea7</td>\n      <td>83271454402288255ea7</td>\n      <td>83271d1df00748d80ea7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316679</th>\n      <td>LOCAL</td>\n      <td>1590517477999</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>83271e7a984122e21ea7</td>\n      <td>83271547136688f66ea7</td>\n      <td>83271064f56158551ea7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316706</th>\n      <td>LOCAL</td>\n      <td>1590517478114</td>\n      <td>82.0</td>\n      <td>False</td>\n      <td>832717527302222f1ea7</td>\n      <td>83271e970f40092e6ea7</td>\n      <td>83271d80887558e12ea7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316711</th>\n      <td>LOCAL</td>\n      <td>1590517478202</td>\n      <td>5.0</td>\n      <td>False</td>\n      <td>83271cce070298a51ea7</td>\n      <td>83271341cb6209a37ea7</td>\n      <td>832713faaa2458f51ea7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n    <tr>\n      <th>2316712</th>\n      <td>LOCAL</td>\n      <td>1590517478204</td>\n      <td>4.0</td>\n      <td>False</td>\n      <td>83271df45d8098ed1ea7</td>\n      <td>8327115a2b1309c37ea7</td>\n      <td>8327111f799558e12ea7</td>\n      <td>docker_003</td>\n      <td>db_007</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 65
    }
   ],
   "source": [
    "ldf[ldf.serviceName=='db_007'].sort_values('startTime').tail(60)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "df1 = df[df['callType']=='RemoteProcess']\n",
    "df1 = df1[['pid','cmdb_id']]\n",
    "df1 = df1.set_index('pid')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "elapse_time = {}\n",
    "children = {}\n",
    "\n",
    "def do_thing(row):\n",
    "    if row['id'] in df1.index:\n",
    "        row['serviceName'] = df1.at[row['id'],'cmdb_id']\n",
    "    if row['pid'] != 'None':\n",
    "        children[row['pid']] = children.get(row['pid'], [])\n",
    "        children[row['pid']].append(row['id'])\n",
    "    elapse_time[row['id']] = float(row['elapsedTime'])\n",
    "    return row\n",
    "df = df.apply(do_thing, axis=1)\n",
    "\n",
    "\n",
    "df['actual_time'] = 0.0\n",
    "\n",
    "def get_actual_time(row):\n",
    "    total_child = 0.0\n",
    "    if row['id'] in children:\n",
    "        for child in children[row['id']]:\n",
    "            total_child += elapse_time[child]\n",
    "    row['actual_time'] = row['elapsedTime'] - total_child\n",
    "    return row\n",
    "\n",
    "df = df.apply(get_actual_time, axis = 1)\n",
    "\n",
    "df = df[~(df['serviceName'].str.contains('csf', na=True))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.sort_values(['traceId', 'startTime'], ignore_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "         callType      startTime  elapsedTime  success               traceId  \\\n",
       "0             OSB  1590528486598        243.0     True  932710000a04776c0e22   \n",
       "1             CSF  1590528486610        226.0     True  932710000a04776c0e22   \n",
       "2   RemoteProcess  1590528486610        224.0     True  932710000a04776c0e22   \n",
       "3       FlyRemote  1590528486613          7.0     True  932710000a04776c0e22   \n",
       "4             CSF  1590528486621         35.0     True  932710000a04776c0e22   \n",
       "5   RemoteProcess  1590528486623         32.0     True  932710000a04776c0e22   \n",
       "6           LOCAL  1590528486643          7.0     True  932710000a04776c0e22   \n",
       "7             CSF  1590528486657         23.0     True  932710000a04776c0e22   \n",
       "8   RemoteProcess  1590528486658         20.0     True  932710000a04776c0e22   \n",
       "9           LOCAL  1590528486662          6.0     True  932710000a04776c0e22   \n",
       "10          LOCAL  1590528486669          3.0     True  932710000a04776c0e22   \n",
       "11            CSF  1590528486684         52.0     True  932710000a04776c0e22   \n",
       "12  RemoteProcess  1590528486716         19.0     True  932710000a04776c0e22   \n",
       "13          LOCAL  1590528486720          5.0     True  932710000a04776c0e22   \n",
       "14          LOCAL  1590528486726          3.0     True  932710000a04776c0e22   \n",
       "15            CSF  1590528486737         16.0     True  932710000a04776c0e22   \n",
       "16  RemoteProcess  1590528486739         14.0     True  932710000a04776c0e22   \n",
       "17          LOCAL  1590528486742          6.0     True  932710000a04776c0e22   \n",
       "18          LOCAL  1590528486754          1.0     True  932710000a04776c0e22   \n",
       "19          LOCAL  1590528486755          2.0     True  932710000a04776c0e22   \n",
       "20          LOCAL  1590528486757          2.0     True  932710000a04776c0e22   \n",
       "21          LOCAL  1590528486759          1.0     True  932710000a04776c0e22   \n",
       "22          LOCAL  1590528486760          2.0     True  932710000a04776c0e22   \n",
       "23          LOCAL  1590528486762          2.0     True  932710000a04776c0e22   \n",
       "24          LOCAL  1590528486764          2.0     True  932710000a04776c0e22   \n",
       "25          LOCAL  1590528486766          2.0     True  932710000a04776c0e22   \n",
       "26          LOCAL  1590528486768          2.0     True  932710000a04776c0e22   \n",
       "27          LOCAL  1590528486770          1.0     True  932710000a04776c0e22   \n",
       "28          LOCAL  1590528486771         44.0     True  932710000a04776c0e22   \n",
       "29          LOCAL  1590528486815          2.0     True  932710000a04776c0e22   \n",
       "30          LOCAL  1590528486817          2.0     True  932710000a04776c0e22   \n",
       "31          LOCAL  1590528486819          9.0     True  932710000a04776c0e22   \n",
       "32            OSB  1590529145868        563.0     True  932710006e2216c00fc2   \n",
       "33            CSF  1590529145874        550.0     True  932710006e2216c00fc2   \n",
       "34  RemoteProcess  1590529145875        547.0     True  932710006e2216c00fc2   \n",
       "35      FlyRemote  1590529145881          9.0     True  932710006e2216c00fc2   \n",
       "36            CSF  1590529145900         57.0     True  932710006e2216c00fc2   \n",
       "37  RemoteProcess  1590529145919         37.0     True  932710006e2216c00fc2   \n",
       "38          LOCAL  1590529145940          8.0     True  932710006e2216c00fc2   \n",
       "39            CSF  1590529145959         26.0     True  932710006e2216c00fc2   \n",
       "40  RemoteProcess  1590529145961         24.0     True  932710006e2216c00fc2   \n",
       "41          LOCAL  1590529145966          7.0     True  932710006e2216c00fc2   \n",
       "42          LOCAL  1590529145975          3.0     True  932710006e2216c00fc2   \n",
       "43            CSF  1590529145987         31.0     True  932710006e2216c00fc2   \n",
       "44  RemoteProcess  1590529145991         26.0     True  932710006e2216c00fc2   \n",
       "45          LOCAL  1590529145996          8.0     True  932710006e2216c00fc2   \n",
       "46          LOCAL  1590529146007          4.0     True  932710006e2216c00fc2   \n",
       "47            CSF  1590529146024         29.0     True  932710006e2216c00fc2   \n",
       "48  RemoteProcess  1590529146030         22.0     True  932710006e2216c00fc2   \n",
       "49          LOCAL  1590529146040          7.0     True  932710006e2216c00fc2   \n",
       "50          LOCAL  1590529146053          3.0     True  932710006e2216c00fc2   \n",
       "51          LOCAL  1590529146056         61.0     True  932710006e2216c00fc2   \n",
       "52          LOCAL  1590529146117          6.0     True  932710006e2216c00fc2   \n",
       "53          LOCAL  1590529146123          3.0     True  932710006e2216c00fc2   \n",
       "54          LOCAL  1590529146126          6.0     True  932710006e2216c00fc2   \n",
       "55          LOCAL  1590529146132         87.0     True  932710006e2216c00fc2   \n",
       "56          LOCAL  1590529146219          4.0     True  932710006e2216c00fc2   \n",
       "57          LOCAL  1590529146223          4.0     True  932710006e2216c00fc2   \n",
       "58          LOCAL  1590529146228          3.0     True  932710006e2216c00fc2   \n",
       "59          LOCAL  1590529146231          4.0     True  932710006e2216c00fc2   \n",
       "\n",
       "                      id                   pid     cmdb_id     serviceName  \\\n",
       "0   93271f2d4014776c0e22                  None      os_022          os_022   \n",
       "1   93271fab5234772d0e22  93271f2d4014776c0e22      os_022      docker_001   \n",
       "2   93271fa1a805212d0e22  93271fab5234772d0e22  docker_001      docker_001   \n",
       "3   93271b96aa25215d0e22  93271fa1a805212d0e22  docker_001  fly_remote_001   \n",
       "4   93271ecf5c6521dd0e22  93271fa1a805212d0e22  docker_001      docker_005   \n",
       "5   932715d6312611fd0e22  93271ecf5c6521dd0e22  docker_005      docker_005   \n",
       "6   932712567e48113f0e22  932715d6312611fd0e22  docker_005          db_003   \n",
       "7   93271254176621101e22  93271fa1a805212d0e22  docker_001      docker_006   \n",
       "8   932714fa537464201e22  93271254176621101e22  docker_006      docker_006   \n",
       "9   932711ed891564601e22  932714fa537464201e22  docker_006          db_003   \n",
       "10  93271106199564d01e22  932714fa537464201e22  docker_006          db_003   \n",
       "11  93271855cd8231c11e22  93271fa1a805212d0e22  docker_001      docker_005   \n",
       "12  93271d7b937021c31e22  93271855cd8231c11e22  docker_005      docker_005   \n",
       "13  9327169fdb1121041e22  93271d7b937021c31e22  docker_005          db_003   \n",
       "14  932714588e9121641e22  93271d7b937021c31e22  docker_005          db_003   \n",
       "15  9327159f7a0531151e22  93271fa1a805212d0e22  docker_001      docker_005   \n",
       "16  932718bef54221351e22  9327159f7a0531151e22  docker_005      docker_005   \n",
       "17  93271c38836221651e22  932718bef54221351e22  docker_005          db_003   \n",
       "18  93271e03094531261e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "19  932718a98d2631361e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "20  932714b7ea7631561e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "21  932710b80e7731761e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "22  93271b73477831861e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "23  9327189ae07931a61e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "24  93271c474b0141c61e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "25  932711b0050241e61e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "26  932719e1fc0341071e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "27  932712b9090441271e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "28  9327117a757441371e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "29  93271837105541f91e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "30  93271c1a4426411a1e22  93271fa1a805212d0e22  docker_001          db_009   \n",
       "31  93271f484607413a1e22  93271fa1a805212d0e22  docker_001          db_007   \n",
       "32  932713e7e73216c00fc2                  None      os_022          os_022   \n",
       "33  932714e0b87216210fc2  932713e7e73216c00fc2      os_022      docker_001   \n",
       "34  93271dfd9c6721310fc2  932714e0b87216210fc2  docker_001      docker_001   \n",
       "35  93271b7eca4821910fc2  93271dfd9c6721310fc2  docker_001  fly_remote_001   \n",
       "36  932719dbd70031920fc2  93271dfd9c6721310fc2  docker_001      docker_005   \n",
       "37  93271ceb7d3783f30fc2  932719dbd70031920fc2  docker_005      docker_005   \n",
       "38  9327104ee51093450fc2  93271ceb7d3783f30fc2  docker_005          db_003   \n",
       "39  932715abb42131760fc2  93271dfd9c6721310fc2  docker_001      docker_006   \n",
       "40  932718caeb2756960fc2  932715abb42131760fc2  docker_006      docker_006   \n",
       "41  93271901276756e60fc2  932718caeb2756960fc2  docker_006          db_003   \n",
       "42  93271f02f86956770fc2  932718caeb2756960fc2  docker_006          db_003   \n",
       "43  9327197cef0231380fc2  93271dfd9c6721310fc2  docker_001      docker_005   \n",
       "44  93271e55b86693780fc2  9327197cef0231380fc2  docker_005      docker_005   \n",
       "45  9327159f765793c80fc2  93271e55b86693780fc2  docker_005          db_003   \n",
       "46  932710306d1993790fc2  93271e55b86693780fc2  docker_005          db_003   \n",
       "47  932713b50a62317a0fc2  93271dfd9c6721310fc2  docker_001      docker_005   \n",
       "48  932710db590104ea0fc2  932713b50a62317a0fc2  docker_005      docker_005   \n",
       "49  932715fd4942048b0fc2  932710db590104ea0fc2  docker_005          db_003   \n",
       "50  9327149d0043315c0fc2  93271dfd9c6721310fc2  docker_001          db_009   \n",
       "51  932715740105318c0fc2  93271dfd9c6721310fc2  docker_001          db_009   \n",
       "52  932717f5955731501fc2  93271dfd9c6721310fc2  docker_001          db_009   \n",
       "53  93271572390931b01fc2  93271dfd9c6721310fc2  docker_001          db_009   \n",
       "54  9327184f511041e01fc2  93271dfd9c6721310fc2  docker_001          db_009   \n",
       "55  93271cd7be4241411fc2  93271dfd9c6721310fc2  docker_001          db_009   \n",
       "56  932712a54f3641b61fc2  93271dfd9c6721310fc2  docker_001          db_009   \n",
       "57  9327142b595741f61fc2  93271dfd9c6721310fc2  docker_001          db_009   \n",
       "58  932714520b3941471fc2  93271dfd9c6721310fc2  docker_001          db_009   \n",
       "59  93271aafe00151771fc2  93271dfd9c6721310fc2  docker_001          db_009   \n",
       "\n",
       "    actual_time  \n",
       "0          17.0  \n",
       "1           2.0  \n",
       "2          17.0  \n",
       "3           7.0  \n",
       "4           3.0  \n",
       "5          25.0  \n",
       "6           7.0  \n",
       "7           3.0  \n",
       "8          11.0  \n",
       "9           6.0  \n",
       "10          3.0  \n",
       "11         33.0  \n",
       "12         11.0  \n",
       "13          5.0  \n",
       "14          3.0  \n",
       "15          2.0  \n",
       "16          8.0  \n",
       "17          6.0  \n",
       "18          1.0  \n",
       "19          2.0  \n",
       "20          2.0  \n",
       "21          1.0  \n",
       "22          2.0  \n",
       "23          2.0  \n",
       "24          2.0  \n",
       "25          2.0  \n",
       "26          2.0  \n",
       "27          1.0  \n",
       "28         44.0  \n",
       "29          2.0  \n",
       "30          2.0  \n",
       "31          9.0  \n",
       "32         13.0  \n",
       "33          3.0  \n",
       "34        111.0  \n",
       "35          9.0  \n",
       "36         20.0  \n",
       "37         29.0  \n",
       "38          8.0  \n",
       "39          2.0  \n",
       "40         14.0  \n",
       "41          7.0  \n",
       "42          3.0  \n",
       "43          5.0  \n",
       "44         14.0  \n",
       "45          8.0  \n",
       "46          4.0  \n",
       "47          7.0  \n",
       "48         15.0  \n",
       "49          7.0  \n",
       "50          3.0  \n",
       "51         61.0  \n",
       "52          6.0  \n",
       "53          3.0  \n",
       "54          6.0  \n",
       "55         87.0  \n",
       "56          4.0  \n",
       "57          4.0  \n",
       "58          3.0  \n",
       "59          4.0  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>callType</th>\n      <th>startTime</th>\n      <th>elapsedTime</th>\n      <th>success</th>\n      <th>traceId</th>\n      <th>id</th>\n      <th>pid</th>\n      <th>cmdb_id</th>\n      <th>serviceName</th>\n      <th>actual_time</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>OSB</td>\n      <td>1590528486598</td>\n      <td>243.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271f2d4014776c0e22</td>\n      <td>None</td>\n      <td>os_022</td>\n      <td>os_022</td>\n      <td>17.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>CSF</td>\n      <td>1590528486610</td>\n      <td>226.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271fab5234772d0e22</td>\n      <td>93271f2d4014776c0e22</td>\n      <td>os_022</td>\n      <td>docker_001</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>RemoteProcess</td>\n      <td>1590528486610</td>\n      <td>224.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>93271fab5234772d0e22</td>\n      <td>docker_001</td>\n      <td>docker_001</td>\n      <td>17.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>FlyRemote</td>\n      <td>1590528486613</td>\n      <td>7.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271b96aa25215d0e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>fly_remote_001</td>\n      <td>7.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>CSF</td>\n      <td>1590528486621</td>\n      <td>35.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271ecf5c6521dd0e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>docker_005</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>RemoteProcess</td>\n      <td>1590528486623</td>\n      <td>32.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932715d6312611fd0e22</td>\n      <td>93271ecf5c6521dd0e22</td>\n      <td>docker_005</td>\n      <td>docker_005</td>\n      <td>25.0</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>LOCAL</td>\n      <td>1590528486643</td>\n      <td>7.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932712567e48113f0e22</td>\n      <td>932715d6312611fd0e22</td>\n      <td>docker_005</td>\n      <td>db_003</td>\n      <td>7.0</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>CSF</td>\n      <td>1590528486657</td>\n      <td>23.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271254176621101e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>docker_006</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>RemoteProcess</td>\n      <td>1590528486658</td>\n      <td>20.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932714fa537464201e22</td>\n      <td>93271254176621101e22</td>\n      <td>docker_006</td>\n      <td>docker_006</td>\n      <td>11.0</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>LOCAL</td>\n      <td>1590528486662</td>\n      <td>6.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932711ed891564601e22</td>\n      <td>932714fa537464201e22</td>\n      <td>docker_006</td>\n      <td>db_003</td>\n      <td>6.0</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>LOCAL</td>\n      <td>1590528486669</td>\n      <td>3.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271106199564d01e22</td>\n      <td>932714fa537464201e22</td>\n      <td>docker_006</td>\n      <td>db_003</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>CSF</td>\n      <td>1590528486684</td>\n      <td>52.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271855cd8231c11e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>docker_005</td>\n      <td>33.0</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>RemoteProcess</td>\n      <td>1590528486716</td>\n      <td>19.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271d7b937021c31e22</td>\n      <td>93271855cd8231c11e22</td>\n      <td>docker_005</td>\n      <td>docker_005</td>\n      <td>11.0</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>LOCAL</td>\n      <td>1590528486720</td>\n      <td>5.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>9327169fdb1121041e22</td>\n      <td>93271d7b937021c31e22</td>\n      <td>docker_005</td>\n      <td>db_003</td>\n      <td>5.0</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>LOCAL</td>\n      <td>1590528486726</td>\n      <td>3.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932714588e9121641e22</td>\n      <td>93271d7b937021c31e22</td>\n      <td>docker_005</td>\n      <td>db_003</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>CSF</td>\n      <td>1590528486737</td>\n      <td>16.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>9327159f7a0531151e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>docker_005</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>RemoteProcess</td>\n      <td>1590528486739</td>\n      <td>14.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932718bef54221351e22</td>\n      <td>9327159f7a0531151e22</td>\n      <td>docker_005</td>\n      <td>docker_005</td>\n      <td>8.0</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>LOCAL</td>\n      <td>1590528486742</td>\n      <td>6.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271c38836221651e22</td>\n      <td>932718bef54221351e22</td>\n      <td>docker_005</td>\n      <td>db_003</td>\n      <td>6.0</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>LOCAL</td>\n      <td>1590528486754</td>\n      <td>1.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271e03094531261e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>LOCAL</td>\n      <td>1590528486755</td>\n      <td>2.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932718a98d2631361e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>LOCAL</td>\n      <td>1590528486757</td>\n      <td>2.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932714b7ea7631561e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>LOCAL</td>\n      <td>1590528486759</td>\n      <td>1.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932710b80e7731761e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>LOCAL</td>\n      <td>1590528486760</td>\n      <td>2.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271b73477831861e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>LOCAL</td>\n      <td>1590528486762</td>\n      <td>2.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>9327189ae07931a61e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>LOCAL</td>\n      <td>1590528486764</td>\n      <td>2.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271c474b0141c61e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>LOCAL</td>\n      <td>1590528486766</td>\n      <td>2.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932711b0050241e61e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>LOCAL</td>\n      <td>1590528486768</td>\n      <td>2.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932719e1fc0341071e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>LOCAL</td>\n      <td>1590528486770</td>\n      <td>1.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>932712b9090441271e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>LOCAL</td>\n      <td>1590528486771</td>\n      <td>44.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>9327117a757441371e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>44.0</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>LOCAL</td>\n      <td>1590528486815</td>\n      <td>2.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271837105541f91e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>30</th>\n      <td>LOCAL</td>\n      <td>1590528486817</td>\n      <td>2.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271c1a4426411a1e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>31</th>\n      <td>LOCAL</td>\n      <td>1590528486819</td>\n      <td>9.0</td>\n      <td>True</td>\n      <td>932710000a04776c0e22</td>\n      <td>93271f484607413a1e22</td>\n      <td>93271fa1a805212d0e22</td>\n      <td>docker_001</td>\n      <td>db_007</td>\n      <td>9.0</td>\n    </tr>\n    <tr>\n      <th>32</th>\n      <td>OSB</td>\n      <td>1590529145868</td>\n      <td>563.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932713e7e73216c00fc2</td>\n      <td>None</td>\n      <td>os_022</td>\n      <td>os_022</td>\n      <td>13.0</td>\n    </tr>\n    <tr>\n      <th>33</th>\n      <td>CSF</td>\n      <td>1590529145874</td>\n      <td>550.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932714e0b87216210fc2</td>\n      <td>932713e7e73216c00fc2</td>\n      <td>os_022</td>\n      <td>docker_001</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>34</th>\n      <td>RemoteProcess</td>\n      <td>1590529145875</td>\n      <td>547.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>932714e0b87216210fc2</td>\n      <td>docker_001</td>\n      <td>docker_001</td>\n      <td>111.0</td>\n    </tr>\n    <tr>\n      <th>35</th>\n      <td>FlyRemote</td>\n      <td>1590529145881</td>\n      <td>9.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>93271b7eca4821910fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>fly_remote_001</td>\n      <td>9.0</td>\n    </tr>\n    <tr>\n      <th>36</th>\n      <td>CSF</td>\n      <td>1590529145900</td>\n      <td>57.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932719dbd70031920fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>docker_005</td>\n      <td>20.0</td>\n    </tr>\n    <tr>\n      <th>37</th>\n      <td>RemoteProcess</td>\n      <td>1590529145919</td>\n      <td>37.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>93271ceb7d3783f30fc2</td>\n      <td>932719dbd70031920fc2</td>\n      <td>docker_005</td>\n      <td>docker_005</td>\n      <td>29.0</td>\n    </tr>\n    <tr>\n      <th>38</th>\n      <td>LOCAL</td>\n      <td>1590529145940</td>\n      <td>8.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>9327104ee51093450fc2</td>\n      <td>93271ceb7d3783f30fc2</td>\n      <td>docker_005</td>\n      <td>db_003</td>\n      <td>8.0</td>\n    </tr>\n    <tr>\n      <th>39</th>\n      <td>CSF</td>\n      <td>1590529145959</td>\n      <td>26.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932715abb42131760fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>docker_006</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>40</th>\n      <td>RemoteProcess</td>\n      <td>1590529145961</td>\n      <td>24.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932718caeb2756960fc2</td>\n      <td>932715abb42131760fc2</td>\n      <td>docker_006</td>\n      <td>docker_006</td>\n      <td>14.0</td>\n    </tr>\n    <tr>\n      <th>41</th>\n      <td>LOCAL</td>\n      <td>1590529145966</td>\n      <td>7.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>93271901276756e60fc2</td>\n      <td>932718caeb2756960fc2</td>\n      <td>docker_006</td>\n      <td>db_003</td>\n      <td>7.0</td>\n    </tr>\n    <tr>\n      <th>42</th>\n      <td>LOCAL</td>\n      <td>1590529145975</td>\n      <td>3.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>93271f02f86956770fc2</td>\n      <td>932718caeb2756960fc2</td>\n      <td>docker_006</td>\n      <td>db_003</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>43</th>\n      <td>CSF</td>\n      <td>1590529145987</td>\n      <td>31.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>9327197cef0231380fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>docker_005</td>\n      <td>5.0</td>\n    </tr>\n    <tr>\n      <th>44</th>\n      <td>RemoteProcess</td>\n      <td>1590529145991</td>\n      <td>26.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>93271e55b86693780fc2</td>\n      <td>9327197cef0231380fc2</td>\n      <td>docker_005</td>\n      <td>docker_005</td>\n      <td>14.0</td>\n    </tr>\n    <tr>\n      <th>45</th>\n      <td>LOCAL</td>\n      <td>1590529145996</td>\n      <td>8.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>9327159f765793c80fc2</td>\n      <td>93271e55b86693780fc2</td>\n      <td>docker_005</td>\n      <td>db_003</td>\n      <td>8.0</td>\n    </tr>\n    <tr>\n      <th>46</th>\n      <td>LOCAL</td>\n      <td>1590529146007</td>\n      <td>4.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932710306d1993790fc2</td>\n      <td>93271e55b86693780fc2</td>\n      <td>docker_005</td>\n      <td>db_003</td>\n      <td>4.0</td>\n    </tr>\n    <tr>\n      <th>47</th>\n      <td>CSF</td>\n      <td>1590529146024</td>\n      <td>29.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932713b50a62317a0fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>docker_005</td>\n      <td>7.0</td>\n    </tr>\n    <tr>\n      <th>48</th>\n      <td>RemoteProcess</td>\n      <td>1590529146030</td>\n      <td>22.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932710db590104ea0fc2</td>\n      <td>932713b50a62317a0fc2</td>\n      <td>docker_005</td>\n      <td>docker_005</td>\n      <td>15.0</td>\n    </tr>\n    <tr>\n      <th>49</th>\n      <td>LOCAL</td>\n      <td>1590529146040</td>\n      <td>7.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932715fd4942048b0fc2</td>\n      <td>932710db590104ea0fc2</td>\n      <td>docker_005</td>\n      <td>db_003</td>\n      <td>7.0</td>\n    </tr>\n    <tr>\n      <th>50</th>\n      <td>LOCAL</td>\n      <td>1590529146053</td>\n      <td>3.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>9327149d0043315c0fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>51</th>\n      <td>LOCAL</td>\n      <td>1590529146056</td>\n      <td>61.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932715740105318c0fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>61.0</td>\n    </tr>\n    <tr>\n      <th>52</th>\n      <td>LOCAL</td>\n      <td>1590529146117</td>\n      <td>6.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932717f5955731501fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>6.0</td>\n    </tr>\n    <tr>\n      <th>53</th>\n      <td>LOCAL</td>\n      <td>1590529146123</td>\n      <td>3.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>93271572390931b01fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>54</th>\n      <td>LOCAL</td>\n      <td>1590529146126</td>\n      <td>6.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>9327184f511041e01fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>6.0</td>\n    </tr>\n    <tr>\n      <th>55</th>\n      <td>LOCAL</td>\n      <td>1590529146132</td>\n      <td>87.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>93271cd7be4241411fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>87.0</td>\n    </tr>\n    <tr>\n      <th>56</th>\n      <td>LOCAL</td>\n      <td>1590529146219</td>\n      <td>4.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932712a54f3641b61fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>4.0</td>\n    </tr>\n    <tr>\n      <th>57</th>\n      <td>LOCAL</td>\n      <td>1590529146223</td>\n      <td>4.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>9327142b595741f61fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>4.0</td>\n    </tr>\n    <tr>\n      <th>58</th>\n      <td>LOCAL</td>\n      <td>1590529146228</td>\n      <td>3.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>932714520b3941471fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>59</th>\n      <td>LOCAL</td>\n      <td>1590529146231</td>\n      <td>4.0</td>\n      <td>True</td>\n      <td>932710006e2216c00fc2</td>\n      <td>93271aafe00151771fc2</td>\n      <td>93271dfd9c6721310fc2</td>\n      <td>docker_001</td>\n      <td>db_009</td>\n      <td>4.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 14
    }
   ],
   "source": [
    "df.head(60)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "save_path ='D:\\\\THU Studies\\\\Advance Network Management\\\\Project\\\\Anomaly-detection\\\\local_data\\\\esd\\\\'\n",
    "df.to_csv(save_path+'trace_528347_os18.csv', index = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from tqdm import tqdm\n",
    "for index, row in tqdm(df.iterrows()):\n",
    "    if row['id'] in csf_cmdb:\n",
    "        df.at[index, 'serviceName'] = csf_cmdb[row['id']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "elapse_time = {}\n",
    "children = {}\n",
    "for index, row in tqdm(df.iterrows()):\n",
    "    if row['pid'] != 'None':\n",
    "        if row['pid'] in children.keys():\n",
    "            children[row['pid']].append(row['id'])\n",
    "        else:\n",
    "            children[row['pid']] = [row['id']]\n",
    "    elapse_time[row['id']] = float(row['elapsedTime'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df['actual_time'] = 0.0\n",
    "for index, row in tqdm(df.iterrows()):\n",
    "    total_child = 0.0\n",
    "    if row['id'] not in children.keys():\n",
    "        df.at[index, 'actual_time'] = row['elapsedTime']\n",
    "        continue\n",
    "    for child in children[row['id']]:\n",
    "        total_child += elapse_time[child]\n",
    "    df.at[index, 'actual_time'] = row['elapsedTime'] - total_child"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.sort_values(['traceId','startTime','callType'], ignore_index = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.serviceName.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.head(60)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "grouped_df = df.groupby(['cmdb_id', 'serviceName'])[['startTime','actual_time']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "dict_keys([('docker_001', 'db_007'), ('docker_001', 'db_009'), ('docker_001', 'docker_001'), ('docker_001', 'docker_005'), ('docker_001', 'docker_006'), ('docker_001', 'fly_remote_001'), ('docker_002', 'db_007'), ('docker_002', 'db_009'), ('docker_002', 'docker_002'), ('docker_002', 'docker_005'), ('docker_002', 'docker_006'), ('docker_002', 'fly_remote_001'), ('docker_003', 'db_007'), ('docker_003', 'db_009'), ('docker_003', 'docker_003'), ('docker_003', 'docker_007'), ('docker_003', 'docker_008'), ('docker_003', 'fly_remote_001'), ('docker_004', 'db_007'), ('docker_004', 'db_009'), ('docker_004', 'docker_004'), ('docker_004', 'docker_007'), ('docker_004', 'docker_008'), ('docker_004', 'fly_remote_001'), ('docker_005', 'db_003'), ('docker_005', 'docker_005'), ('docker_006', 'db_003'), ('docker_006', 'docker_006'), ('docker_007', 'db_003'), ('docker_007', 'docker_007'), ('docker_007', 'fly_remote_001'), ('docker_008', 'db_003'), ('docker_008', 'docker_008'), ('docker_008', 'fly_remote_001'), ('os_021', 'docker_003'), ('os_021', 'docker_004'), ('os_021', 'os_021'), ('os_022', 'docker_001'), ('os_022', 'docker_002'), ('os_022', 'os_022')])"
      ]
     },
     "metadata": {},
     "execution_count": 15
    }
   ],
   "source": [
    "grouped_df.groups.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "def esd_test_statistics(x, hybrid=True):\n",
    "  \"\"\"\n",
    "  Compute the location and dispersion sample statistics used to carry out the ESD test.\n",
    "  \"\"\"\n",
    "  if hybrid:\n",
    "    location = pd.Series(x).median(skipna=True) # Median\n",
    "    dispersion = np.median(np.abs(x - np.median(x))) # Median Absolute Deviation\n",
    "  else:  \n",
    "    location = pd.Series(x).mean(skipna=True) # Mean\n",
    "    dispersion = pd.Series(x).std(skipna=True) # Standard Deviation\n",
    "    \n",
    "  return location, dispersion    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "# def seasonal_mean(x, freq):\n",
    "#   \"\"\"\n",
    "#   Returns the mean of the timeseries for each period in x.\n",
    "  \n",
    "#   x    : List, array, or series containing the time series\n",
    "#   freq : Int that gives the number of periods per cycle (7 for week, 12 for monthly, etc)\n",
    "#   \"\"\"\n",
    "#   return np.array([pd.Series(x[i::freq]).mean(skipna=True) for i in range(freq)])\n",
    "\n",
    "def ts_S_Md_decomposition(x):\n",
    "  \"\"\"\n",
    "  Decomposes the timeseries using a modified STL method:Rx = X - Sx - X^~.\n",
    "    Rx : Residuals\n",
    "    X  : Original time series\n",
    "    Sx : Seasonality component (average value per period)\n",
    "    X^~: Median of original timeseries\n",
    "    \n",
    "  x    : List, array, or series containing the time series \n",
    "  freq : Int that gives the number of periods per cycle (7 for week, 12 for monthly, etc)  \n",
    "  \"\"\"\n",
    "  nobs = len(x)\n",
    "  \n",
    "  # Seasonality\n",
    "#   period_averages = seasonal_mean(x, freq)\n",
    "#   seasonal = np.tile(period_averages, nobs // freq + 1)[:nobs]\n",
    "  \n",
    "  # Median\n",
    "  med = np.tile(pd.Series(x).median(skipna=True), nobs)\n",
    "  \n",
    "  # Residuals\n",
    "#   res = np.array(x) - seasonal - med\n",
    "  res = np.array(x) - med\n",
    "  return {\"observed\": np.array(x), \"median\":med, \"residual\":res}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [],
   "source": [
    "def esd_test(x, alpha=0.95, ub=0.499, hybrid=True):\n",
    "  \"\"\"\n",
    "  Carries out the Extreme Studentized Deviate(ESD) test which can be used to detect one or more outliers present in the timeseries\n",
    "  \n",
    "  x      : List, array, or series containing the time series\n",
    "  freq   : Int that gives the number of periods per cycle (7 for week, 12 for monthly, etc)\n",
    "  alpha  : Confidence level in detecting outliers\n",
    "  ub     : Upper bound on the fraction of datapoints which can be labeled as outliers (<=0.499)\n",
    "  hybrid : Whether to use the robust statistics (median, median absolute error) or the non-robust versions (mean, standard deviation) to test for anomalies\n",
    "  \"\"\"\n",
    "  nobs = len(x)\n",
    "  if ub > 0.4999:\n",
    "    ub = 0.499\n",
    "  k = max(int(np.floor(ub * nobs)), 1) # Maximum number of anomalies. At least 1 anomaly must be tested.\n",
    "#   res_tmp = ts_S_Md_decomposition(x)[\"residual\"] # Residuals from time series decomposition\n",
    "    \n",
    "  # Carry out the esd test k times  \n",
    "\n",
    "  res = np.ma.array(x, mask=False) # The \"ma\" structure allows masking of values to exclude the elements from any calculation\n",
    "  anomalies = [] # returns the indices of the found anomalies\n",
    "  med = np.median(x)\n",
    "  ctr = 0\n",
    "  for i in range(1, k+1):\n",
    "      location, dispersion = esd_test_statistics(res, hybrid) # Sample statistics\n",
    "      tmp = np.abs(res - location) / dispersion\n",
    "      idx = np.argmax(tmp) # Index of the test statistic\n",
    "      test_statistic = tmp[idx]\n",
    "      n = nobs - res.mask.sum() # sums  nonmasked values\n",
    "      critical_value = (n - i) * t.ppf(alpha, n - i - 1) / np.sqrt((n - i - 1 + np.power(t.ppf(alpha, n - i - 1), 2)) * (n - i - 1)) \n",
    "      if test_statistic > critical_value:\n",
    "          ctr += 1\n",
    "          anomalies.append((x[idx]-med) / med)\n",
    "          # anomalies.append(test_statistic)\n",
    "      res.mask[idx] = True\n",
    "  if len(anomalies) == 0:\n",
    "      return 0\n",
    "  # return np.mean(np.abs(anomalies))\n",
    "  return ctr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "dict_keys([('docker_001', 'db_007'), ('docker_001', 'db_009'), ('docker_001', 'docker_001'), ('docker_001', 'docker_005'), ('docker_001', 'docker_006'), ('docker_001', 'fly_remote_001'), ('docker_002', 'db_007'), ('docker_002', 'db_009'), ('docker_002', 'docker_002'), ('docker_002', 'docker_005'), ('docker_002', 'docker_006'), ('docker_002', 'fly_remote_001'), ('docker_003', 'db_007'), ('docker_003', 'db_009'), ('docker_003', 'docker_003'), ('docker_003', 'docker_007'), ('docker_003', 'docker_008'), ('docker_003', 'fly_remote_001'), ('docker_004', 'db_007'), ('docker_004', 'db_009'), ('docker_004', 'docker_004'), ('docker_004', 'docker_007'), ('docker_004', 'docker_008'), ('docker_004', 'fly_remote_001'), ('docker_005', 'db_003'), ('docker_005', 'docker_005'), ('docker_006', 'db_003'), ('docker_006', 'docker_006'), ('docker_007', 'db_003'), ('docker_007', 'docker_007'), ('docker_007', 'fly_remote_001'), ('docker_008', 'db_003'), ('docker_008', 'docker_008'), ('docker_008', 'fly_remote_001'), ('os_021', 'docker_003'), ('os_021', 'docker_004'), ('os_021', 'os_021'), ('os_022', 'docker_001'), ('os_022', 'docker_002'), ('os_022', 'os_022')])"
      ]
     },
     "metadata": {},
     "execution_count": 22
    }
   ],
   "source": [
    "grouped_df.groups.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "class RCA():\n",
    "    def local_initiate(self):\n",
    "        self.dockers = ['docker_001', 'docker_002', 'docker_003', 'docker_004',\n",
    "                'docker_005', 'docker_006', 'docker_007', 'docker_008']\n",
    "        self.docker_hosts = ['os_017', 'os_018', 'os_019', 'os_020']\n",
    "\n",
    "        self.docker_kpi_names = ['container_cpu_used', None]\n",
    "        self.os_kpi_names = ['Sent_queue', 'Received_queue']\n",
    "        self.db_kpi_names = ['Proc_User_Used_Pct','Proc_Used_Pct','Sess_Connect','On_Off_State', 'tnsping_result_time']\n",
    "\n",
    "        self.docker_lookup_table = {}\n",
    "        for i in range(len(self.dockers)):\n",
    "            self.docker_lookup_table[self.dockers[i]] = self.docker_hosts[i % 4]\n",
    "            \n",
    "    def find_anomalous_rows(self, min_threshold = 5):\n",
    "        table = self.anomaly_chart.copy()\n",
    "        threshold = max( 0.5 * table.stack().max(), min_threshold)\n",
    "        dodgy_rows = []\n",
    "        just_rows = []\n",
    "        for column in table:\n",
    "            v = 0\n",
    "            r = ''\n",
    "            for index, row in table.iterrows():\n",
    "                if (row[column] > threshold):\n",
    "                    if index == column:\n",
    "                        dodgy_rows.append([index, row[column]])\n",
    "                        just_rows.append(index)\n",
    "                        break\n",
    "                    elif (row[column] > v):\n",
    "                        v = row[column]\n",
    "                        r = index\n",
    "            if r != '':\n",
    "                dodgy_rows.append([r, column, v])\n",
    "                just_rows.append(r)\n",
    "        \n",
    "        output = self.localize(dodgy_rows, list(set(just_rows)))\n",
    "        return output\n",
    "\n",
    "\n",
    "    def find_anomalous_kpi(self, cmdb_id):\n",
    "        kpi_names = []\n",
    "        if 'os' in cmdb_id:\n",
    "            kpi_names = self.os_kpi_names\n",
    "        elif 'docker' in cmdb_id:\n",
    "            kpi_names = self.docker_kpi_names\n",
    "        else:\n",
    "            kpi_names = self.db_kpi_names\n",
    "\n",
    "        return kpi_names\n",
    "\n",
    "\n",
    "    def localize(self, dodgy_rows, just_rows):\n",
    "        n = len(just_rows)\n",
    "        if n < 1:\n",
    "            return None\n",
    "        if n == 1:\n",
    "            KPIs = self.find_anomalous_kpi(just_rows[0])\n",
    "            to_be_sent = []\n",
    "            for KPI in KPIs:\n",
    "                to_be_sent.append([just_rows[0], KPI])\n",
    "            return to_be_sent\n",
    "        if n == 2:\n",
    "            r0 = just_rows[0]\n",
    "            r1 = just_rows[1]\n",
    "            if ('os' in r0) and ('os' in r1):\n",
    "                KPI = self.find_anomalous_kpi('os_001')\n",
    "                return [['os_001', KPI[0]],['os_001', KPI[1]]]\n",
    "            elif ('docker' in r0) and ('docker' in r1):\n",
    "                if self.docker_lookup_table[r0] == self.docker_lookup_table[r1]:\n",
    "                    KPI = self.find_anomalous_kpi(self.docker_lookup_table[r0])\n",
    "                    return [[self.docker_lookup_table[r0], KPI]]\n",
    "            else:\n",
    "                KPI0s = self.find_anomalous_kpi(r0)\n",
    "                KPI1s = self.find_anomalous_kpi(r1)\n",
    "                to_be_sent = []\n",
    "                for kpi in KPI0s:\n",
    "                    to_be_sent.append([r0, kpi])\n",
    "                for kpi in KPI1s:\n",
    "                    to_be_sent.append([r1, kpi])\n",
    "                return to_be_sent\n",
    "        if n > 2:\n",
    "            dodgy_rows.sort(key = lambda x: x[2], reverse = True)\n",
    "            just_rows = [x[0] for x in dodgy_rows]\n",
    "            just_rows = list(set(just_rows))\n",
    "            return self.localize(dodgy_rows[:2], just_rows[:2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "output_type": "error",
     "ename": "NameError",
     "evalue": "name 'anomaly_chart' is not defined",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-19-6299aa9b0634>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mrca\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mRCA\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mrca\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlocal_initiate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 3\u001b[1;33m \u001b[0mrca\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0manomaly_chart\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0manomaly_chart\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      4\u001b[0m \u001b[0moutput\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrca\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfind_anomalous_rows\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'anomaly_chart' is not defined"
     ]
    }
   ],
   "source": [
    "rca = RCA()\n",
    "rca.local_initiate()\n",
    "rca.anomaly_chart = anomaly_chart\n",
    "output = rca.find_anomalous_rows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "output"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [],
   "source": [
    "anomaly_chart = pd.DataFrame()\n",
    "for (a, b), value in grouped_df:\n",
    "    value['time_group'] = value.startTime//60000\n",
    "    # value['date'] = pd.to_datetime(value.startTime, unit='ms') + pd.Timedelta('08:00:00')\n",
    "    # value = value.set_index(pd.DatetimeIndex(value['date']))\n",
    "    # value['rollingTime'] = df.rolling(20,'1min').actual_time.mean()\n",
    "    value = value.groupby(['time_group'])['actual_time'].mean().reset_index()\n",
    "    result = esd_test(value['actual_time'].to_numpy(), alpha=0.95, ub=0.4, hybrid=True)\n",
    "    anomaly_chart.loc[b,a] = result\n",
    "    # print(a,b,' = ',len(result)/len(value)*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "                docker_001  docker_002  docker_003  docker_004  docker_005  \\\n",
       "db_003                 NaN         NaN         NaN         NaN        25.0   \n",
       "db_007                36.0        43.0        39.0        44.0         NaN   \n",
       "db_009                42.0        42.0        41.0        44.0         NaN   \n",
       "docker_001            42.0         NaN         NaN         NaN         NaN   \n",
       "docker_002             NaN        39.0         NaN         NaN         NaN   \n",
       "docker_003             NaN         NaN        43.0         NaN         NaN   \n",
       "docker_004             NaN         NaN         NaN        53.0         NaN   \n",
       "docker_005            42.0        39.0         NaN         NaN        21.0   \n",
       "docker_006            42.0        38.0         NaN         NaN         NaN   \n",
       "docker_007             NaN         NaN        34.0        43.0         NaN   \n",
       "docker_008             NaN         NaN        36.0        40.0         NaN   \n",
       "fly_remote_001        25.0        54.0        52.0        50.0         NaN   \n",
       "os_021                 NaN         NaN         NaN         NaN         NaN   \n",
       "os_022                 NaN         NaN         NaN         NaN         NaN   \n",
       "\n",
       "                docker_006  docker_007  docker_008  os_021  os_022  \n",
       "db_003                45.0        40.0        41.0     NaN     NaN  \n",
       "db_007                 NaN         NaN         NaN     NaN     NaN  \n",
       "db_009                 NaN         NaN         NaN     NaN     NaN  \n",
       "docker_001             NaN         NaN         NaN     NaN    44.0  \n",
       "docker_002             NaN         NaN         NaN     NaN    34.0  \n",
       "docker_003             NaN         NaN         NaN    39.0     NaN  \n",
       "docker_004             NaN         NaN         NaN    42.0     NaN  \n",
       "docker_005             NaN         NaN         NaN     NaN     NaN  \n",
       "docker_006            32.0         NaN         NaN     NaN     NaN  \n",
       "docker_007             NaN        35.0         NaN     NaN     NaN  \n",
       "docker_008             NaN         NaN        41.0     NaN     NaN  \n",
       "fly_remote_001         NaN         3.0         2.0     NaN     NaN  \n",
       "os_021                 NaN         NaN         NaN    24.0     NaN  \n",
       "os_022                 NaN         NaN         NaN     NaN    39.0  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>docker_001</th>\n      <th>docker_002</th>\n      <th>docker_003</th>\n      <th>docker_004</th>\n      <th>docker_005</th>\n      <th>docker_006</th>\n      <th>docker_007</th>\n      <th>docker_008</th>\n      <th>os_021</th>\n      <th>os_022</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>db_003</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>25.0</td>\n      <td>45.0</td>\n      <td>40.0</td>\n      <td>41.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>db_007</th>\n      <td>36.0</td>\n      <td>43.0</td>\n      <td>39.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>db_009</th>\n      <td>42.0</td>\n      <td>42.0</td>\n      <td>41.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>docker_001</th>\n      <td>42.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>44.0</td>\n    </tr>\n    <tr>\n      <th>docker_002</th>\n      <td>NaN</td>\n      <td>39.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>34.0</td>\n    </tr>\n    <tr>\n      <th>docker_003</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>43.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>39.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>docker_004</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>53.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>42.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>docker_005</th>\n      <td>42.0</td>\n      <td>39.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>21.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>docker_006</th>\n      <td>42.0</td>\n      <td>38.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>32.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>docker_007</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>34.0</td>\n      <td>43.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>35.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>docker_008</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>36.0</td>\n      <td>40.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>41.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>fly_remote_001</th>\n      <td>25.0</td>\n      <td>54.0</td>\n      <td>52.0</td>\n      <td>50.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>3.0</td>\n      <td>2.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>os_021</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>24.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>os_022</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>39.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 74
    }
   ],
   "source": [
    "anomaly_chart.sort_index(inplace=True)\n",
    "anomaly_chart"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test = grouped_df.get_group(('docker_008', 'docker_008'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = test[['startTime','actual_time']]\n",
    "# x_val = x['actual_time'].to_numpy()\n",
    "# x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x['time_group'] = x.startTime//10000\n",
    "x = x.groupby(['time_group'])['actual_time'].mean().reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_val = x['actual_time'].to_numpy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "result = esd_test(x_val, freq=3, alpha=0.99, ub=0.4, hybrid=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots()\n",
    "ax.plot(pd.Series(x_val).index, x_val, color=\"blue\", label = \"Original\")\n",
    "ax.scatter(result, x_val[result], color='red', label='Anomaly')\n",
    "plt.legend(loc=\"best\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = test[['startTime','actual_time']]\n",
    "# x_val = x['actual_time'].to_numpy()\n",
    "# x\n",
    "x['time_group'] = x.startTime//1000\n",
    "x = x.groupby(['time_group'])['actual_time'].mean().reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_test = x.copy()\n",
    "x_test.index = pd.to_datetime(x_test['time_group'], unit=\"s\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x_test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}